package StudyCode.summary.myfile;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SecureDirectoryStream;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingSecureDirectoryStream {
	public static void main(String args[]) throws IOException {
		Path path = Paths.get("E:\\迅雷下载\\test1.txt");
		SecureDirectoryStream sds = (SecureDirectoryStream) Files.newDirectoryStream(path);
		PosixFileAttributeView view = (PosixFileAttributeView) sds.getFileAttributeView(PosixFileAttributeView.class);
		PosixFileAttributes attributes = view.readAttributes();
		Set<PosixFilePermission> permissions = attributes.permissions();

		for (PosixFilePermission permission : permissions) {
			System.out.print(permission.toString() + ' ');
		}
		System.out.println();
	}
}
